<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-select v-model="query.farm_id" filterable placeholder="所属农场" style="width: 185px;" class="filter-item">
          <el-option v-for="item in dict.farms" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
        <date-range-picker v-model="query.queryTime" class="date-item" />
<!--        <date-range-picker v-model="query.queryTime" class="date-item" />-->
        <rrOperation />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation  />
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        size="small"
        style="width: 100%;"
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column prop="farm_name" label="所属单位" width="200" />
        <el-table-column prop="field_name" label="田块名称" width="200" />
        <el-table-column prop="can_hun_fei_qty" label="参混肥总量(斤/亩)" width="120" align="center" />
        <el-table-column prop="niao_su_qty" label="尿素总量(斤/亩)" width="120" align="center"/>
        <el-table-column prop="fu_he_fei_qty" label="复合肥总量(斤/亩)" width="120" align="center"/>
        <el-table-column prop="shui_rong_fei_qty" label="水溶肥总量(斤/亩)" width="120" align="center"/>
        <el-table-column prop="fertilizer_count" label="施肥(次)" width="100" align="center"/>
        <el-table-column prop="spray_count" label="施药(次)" width="100" align="center"/>
        <el-table-column prop="ping_zheng_count" label="平整(次)" width="100" align="center"/>
        <el-table-column prop="zhong_zhi_count" label="种植(次)" width="100" align="center"/>
        <el-table-column prop="shou_ge_count" label="收割(次)" width="100" align="center"/>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
/** 种植履历 */
import crudFieldBiz from '@/api/jf/fieldBiz'
import { getFieldListByFarm } from '@/api/jf/public'
import CRUD, { crud, form, header, presenter } from '@crud/V2/crud'
import crudOperation from '@crud/V2/CRUD.operation'
import pagination from '@crud/V2/Pagination'
import rrOperation from '@crud/V2/RR.operation'
import DateRangePicker from '@/components/DateRangePicker'

const defaultForm = {
}
export default {
  name: 'fieldSummary',
  mixins: [presenter(), header()],
  components: { pagination, crudOperation, rrOperation,DateRangePicker },
  cruds() {
    return CRUD({
      url: 'api/v2/biz/farm/fieldSummary'
    })
  },
  dictsV2: ['farms'],
  data() {
    return {
    }
  },
  created() {
    this.crud.optShow = {add: false, edit: false, del: false, download: true}
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      console.log(this.query)
      if(this.query.queryTime){
        this.query.start_time = this.query.queryTime[0]
        this.query.end_time = this.query.queryTime[1]
      }else{
        this.query.start_time = null
        this.query.end_time = null
      }

      return true
    },
  }
}
</script>

<style scoped></style>
